<div class="bs-callout bs-callout-danger">
    <h4><?php echo $data['title']?>
        <div style="float: right;" class="fb-like" data-href="<?php echo base_url(), $slugcategories[$data['categoryid']], '/', $data['slug'];?>" data-layout="button_count" data-action="like" data-show-faces="false" data-share="true"></div>
        <!-- Đặt thẻ này vào phần đầu hoặc ngay trước thẻ đóng phần nội dung của bạn. -->
        <script type="text/javascript" src="https://apis.google.com/js/platform.js">
          {lang: 'vi'}
        </script>
        <!-- Đặt thẻ này vào nơi bạn muốn Nút +1 kết xuất. -->
        <div style="float: right;">
            <div class="g-plusone" data-size="medium"></div>
        </div>
    </h4>
    <p>Đăng bởi: <?php echo $username?> vào lúc <?php echo date('d-m-Y H:i:s', strtotime($data['startdate']))?>
        <span style="float: right;"><?php echo count($comments)?> comments</span>
    </p>
</div>

<div class="bs-callout bs-callout-info">
    <?php echo $data['content']?>
    <?php 
        if(count($olderentry)) echo '<h4>Các bài cũ hơn:</h4>'; 
        foreach($olderentry as $k=>$v) {
    ?>
    <a class="bullets" href="<?php echo base_url(), $parent['slug'], '/', $slugcategories[$v['categoryid']], '/', $v['slug'];?>"><?php echo $v['title']?></a><br />
    <?php }?>
</div>

<div class="bs-callout bs-callout-warning">
    <div style="width: 50%; float: left;">
        <div class="fb-comments" data-href="http://demo.tuvanhiv.net#entry<?php echo $data['id']?>" data-numposts="10" data-colorscheme="light" data-width="379" ></div>
    </div>
    <div style="width: 50%; float: left;">
        <h4></h4>
        <?php if($this->session->userdata('account')) { ?>
        <form id="form" class="form-horizontal" role="form" method="POST">
            <div class="form-group">
                <div class="col-sm-2"></div>
                <div class="col-sm-8">
                    <textarea class="form-control content" placeholder="Lời bình" name="content" ></textarea>
                </div>
                <div class="col-sm-2">
                    <input type="hidden" name="entryid" value="<?php echo $data['id']?>"/>
                    <button type="submit" class="btn btn-primary" id="submit">Gửi</button>
                </div>
            </div>
        </form>
        <?php } else { ?>
        <div style="text-align: right;"><a href="<?php echo base_url().'login'?>">Đăng nhập để gửi bình luận</a></div>
        <?php } ?>
        <div class="comment-block">
            <?php
            foreach($comments as $k=>$v) {
            ?>
                <blockquote class="pull-right" style="text-align: right; width: 100%;">
                    <h6><?php echo $v['content']?></h6>
                    <small>Đăng bởi <?php echo $v['accountid']?> vào lúc <?php echo date('d-m-Y H:i:s', strtotime($v['startdate']))?></small>
                </blockquote>
            <?php
                }
            ?>
        </div>
    </div>
    
    <div class="clearfix"></div>
</div>

<script src="http://js.pusher.com/2.1/pusher.min.js"></script>
<script>
$(function(){
	var pusher = new Pusher('4a714ccbd52501e37d40');
	var channel<?php echo $data['id']?> = pusher.subscribe('entry<?php echo $data['id']?>');
	channel<?php echo $data['id']?>.bind('comment', function(data){
		var html = '<blockquote class="pull-right last" style="text-align: right; width: 100%;"><h6>'+data.comment+'</h6><small>Đăng bởi '+data.name+' vào lúc '+data.date+'</small></blockquote>';
		var comments = $('.comment-block');
		comments.prepend(html);
		comments.find('.last').slideDown().removeClass('last');
	});
	
	$('#form').on('submit', function(){
		var data = $(this).serialize();
		$.post('<?php echo base_url().'ajax/postcomment'?>', data, function(){
			$('#form').trigger('reset');
			return true;
		});
		return false;
	});
});
</script>